Selecting based on __key__ (a unique identifier) in google appengine [Java]
Posted
by Stavros
on Stack Overflow
See other posts from Stack Overflow
or by Stavros
Published on 2010-05-23T23:37:01Z
Indexed on
2010/05/23
23:40 UTC
Read the original article
Hit count: 262
I have
public class QuantityType {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String type;
}
I am trying to setup a query to get the right QuantityType by it's key
gql = "select * from QuantityType where __key__='aght52oobW1hIHTWVzc2FnZRiyAQw'";
But its not working because
BadFilterError: BadFilterError: invalid filter: key filter value must be a Key; received aght52oobW1hIHTWVzc2FnZRiyAQw (a str).
I have also tried to use
gql = "select * from QuantityType where __key__=='" + KeyFactory.stringToKey(qTypeKey)+"'";
but it's now working..
How can I get a specific object from my datastore by it's key?
© Stack Overflow or respective owner